home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / shorts.arc / SHORTS.DOC
Encoding:
Text File  |  1986-10-27  |  4.0 KB  |  95 lines

  1. SHORT SHOTS - Quick Programming tips for the intrepid Clipper user
  2. =========================================================================
  3. Number 1                                          Published June 16, 1986
  4. =========================================================================
  5.  
  6. DILEMMA : You want to de-activate use of the <ALT>C key combination, but
  7.           you still want your user's to be able to use the <ESC> key to
  8.           exit reads and other routines. You can't use SET ESCAPE OFF
  9.           because that will disable both <ALT>C and <ESC>. What to do,
  10.           what to do???
  11.  
  12. SOLUTION: Use a combination of the new Clipper commands, SET KEY and
  13.           KEYBOARD.  Here's the example:
  14.  
  15. *************************************************************************
  16. *** Filename: SETESC.PRG
  17. *** Purpose : Demonstrates method of defeating <ALT>C while leaving
  18. ***           the ESC key active.
  19. *************************************************************************
  20.  
  21. CLEAR
  22. m_name = SPACE(20)
  23.  
  24. SET KEY 302 TO NullKey         && Sets <ALT>C to a null
  25.  
  26. DO WHILE .T.
  27.    @ 5,10 SAY "Your Name: " GET m_name
  28.    READ
  29.    IF TRIM(m_name) == ""
  30.      WAIT "Press any key to Quit..."
  31.      QUIT
  32.    ENDIF
  33. ENDDO
  34.  
  35. *** Procedure NullKey stuffs a null string into the keyboard buffer
  36.  
  37. PROCEDURE NullKey
  38.  
  39. *** supply some dummy parameters so Clipper stays happy
  40.  
  41. PARAMETERS top,bottom,out
  42.  KEYBOARD = ""
  43. RETURN
  44.  
  45. *** EOF SETESC.PRG
  46.  
  47. -More-
  48.  
  49. >>> CLIPPER'S KEYBOARD vs DBASE'S SET TYPEAHEAD
  50.     submitted by David Morgan                     Published June 24, 1986
  51. ==========================================================================
  52.  
  53. Even though Clipper's KEYBOARD command and dBASE's SET TYPEAHEAD command
  54. can acheive some similar results, there are distinct differences in usage
  55. between the two.
  56.  
  57. Both Clipper and dBASE use a keyboard buffer.  This buffer is a holding
  58. area where characters, keyed while a program is running, are stored and not
  59. sent to the screen or otherwise processed by the program immediately. The
  60. buffer places the incoming characters in a queue, (which means that it
  61. "stands them in line" in the same order as they were keyed), from which
  62. characters are extracted by the program on a "first in first out" basis.
  63. Where there is no keyboard buffer in a program, keystrokes occuring while
  64. an application is busy (e.g., performing a lengthy print job) must be
  65. ignored. And the operator has to wait till the program is ready before
  66. keying. dBASE will create a keyboard buffer 20 characters in length and
  67. Clipper will create one of 16 characters, by default.
  68.  
  69. In dBASE, SET TYPEAHEAD actually varies the buffer size. If you use SET
  70. TYPEAHEAD to reduce size of the buffer it will discard all the characters
  71. in the queue that exceed the new buffer size.
  72.  
  73. While Clipper does not allow you to "size" the keyboard buffer, its
  74. KEYBOARD command does allow wholesale replacement of buffer contents. This
  75. really puts buffer contents under your control. For example:
  76.  
  77.    KEYBOARD "ABCD"
  78.  
  79. loads the characters ABCD into the buffer.  Whatever was in there before is
  80. overwritten and at the very next input point in your program (a READ,
  81. ACCEPT, INPUT, WAIT) "ABCD" is issued to the proper output device (screen,
  82. printer, etc.). After this, the keyboard buffer is empty.
  83.  
  84. Both the KEYBOARD and SET TYPEAHEAD commands can be used to flush the
  85. keyboard buffer. In dBASE, 'SET TYPEAHEAD TO 0' will flush any characters
  86. in the buffer and re-set the buffer to a size of zero for the remainder of
  87. the program or until a new SET TYPEAHEAD command is issued. Using the
  88. command line
  89.  
  90.    KEYBOARD ""
  91.  
  92. in Clipper, on the other hand, will clear the buffer only once and must be
  93. issued everytime that you want it flushed.
  94.